package cn.yuanqiao.archive.detail.service.impl;/**
 * @author 赵常飞
 * @date 2023/6/28 15:43
 */

import cn.yuanqiao.archive.Identify.domain.TenantYqKfjdItemFolder;
import cn.yuanqiao.archive.appManager.domain.*;
import cn.yuanqiao.archive.appManager.mapper.ArchiveMapper;
import cn.yuanqiao.archive.appManager.mapper.TenantApplyMapper;
import cn.yuanqiao.archive.appManager.mapper.TenantCategoryMapper;
import cn.yuanqiao.archive.appManager.mapper.TenantYqdaDocumentMapper;
import cn.yuanqiao.archive.appManager.service.ITenantCateMdataListService;
import cn.yuanqiao.archive.appManager.service.ITenantSysConfigService;
import cn.yuanqiao.archive.appManager.service.IYqSyService;
import cn.yuanqiao.archive.detail.bean.WebOFDExplicitWaterMarkInfo;
import cn.yuanqiao.archive.detail.bean.WebOFDPermissionInfo;
import cn.yuanqiao.archive.detail.domain.WebOFDTimeModelEnum;
import cn.yuanqiao.archive.detail.mapper.DetailMapper;
import cn.yuanqiao.archive.detail.service.IDetailService;
import cn.yuanqiao.archive.detail.utils.CommonExtensionUtils;
import cn.yuanqiao.archive.liyong.domain.TenantDownloadRecord;
import cn.yuanqiao.archive.liyong.service.TenantDownloadRecordSerive;
import cn.yuanqiao.archive.utils.FileWaterMark;
import cn.yuanqiao.archive.wenjianzhengli.mapper.WenjianhuishouzhanMapper;
import cn.yuanqiao.archive.wenjianzhengli.service.impl.WenjianzhengliServiceImpl;
import cn.yuanqiao.common.core.context.ResponseUtils;
import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.PageUtils;
import cn.yuanqiao.common.utils.StringUtils;
import cn.yuanqiao.common.utils.SecurityUtils;
import cn.yuanqiao.common.core.domain.model.LoginUser;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.*;

/**
 *
 *@AUTHOR:赵常飞
 *@date 2023/6/28 15:43
 */
@Service
public class DetailServiceImpl implements IDetailService {
    @Autowired
    private DetailMapper detailMapper;
    @Autowired
    private WenjianhuishouzhanMapper wenjianhuishouzhanMapper;
    @Autowired
    private TenantYqdaDocumentMapper tenantYqdaDocumentMapper;
    @Autowired
    private WenjianzhengliServiceImpl wenjianzhengliService;
    @Autowired
    private TenantCategoryMapper categoryMapper;
    @Autowired
    private ITenantCateMdataListService tenantMdataListService;
    @Autowired
    private TenantYqdaDocumentMapper documentMapper;
    @Autowired
    private TenantDownloadRecordSerive tenantDownloadRecordSerive;
    @Autowired
    private IYqSyService yqSyService;
    @Autowired
    private ITenantSysConfigService sysConfigService;
    @Autowired
    private ArchiveMapper archiveMapper;
    @Autowired
    private TenantApplyMapper tenantApplyMapper;

    @Override
    public JSONObject getdatainfo(JSONObject json) {
        JSONObject returnjson=new JSONObject();
        Integer datatype=json.getInteger("datatype");
        Long id=json.getLong("id");
        Integer infotype=json.getInteger("infotype");
        Long categoryId=json.getLong("categoryId");
        String subTableName=json.getString("SubTableName");
        Map<String,String> cateinfo=new HashMap<>();
        TenantCategory tenantCategory=new TenantCategory();
        String catetablename=tenantCategory.getTableName();
        TenantMdataList tenantMdataList=new TenantMdataList();
        String mdatalisttable=tenantMdataList.getTableName();
        TenantYqdaFolder tenantYqdaFolder =new TenantYqdaFolder();
        String fvtable=tenantYqdaFolder.getTableName();//获取卷件关联表
        TenantItemFolder tenantItemFolder=new TenantItemFolder();
        String itemvtable=tenantItemFolder.getTableName();//获取项目卷关联表
        String tableName="";
        String idsql="";
        if(null==categoryId){
            cateinfo=wenjianhuishouzhanMapper.getcateidbysub(catetablename,subTableName).get(0);
            categoryId=Long.parseLong(String.valueOf(cateinfo.get("ID")));
        }else{
            cateinfo=wenjianhuishouzhanMapper.getcateinfobyid(categoryId,catetablename);
        }

        //获取需要查询的字段
        String fields=detailMapper.getfield(mdatalisttable,categoryId,infotype,catetablename);
        //获取数据
        if(0==infotype){//查件层信息
            tableName=cateinfo.get("FILE_TABLE_NAME");
            idsql=String.valueOf(id);
        }else if(1==infotype){
            tableName=cateinfo.get("FOLDER_TABLE_NAME");
            if(1==datatype){//根据卷查卷信息
                idsql=String.valueOf(id);
            }else if(0==datatype){//根据件查卷信息
                idsql="select folder_id from "+fvtable+" where da_id="+id;
            }
        }else if(3==infotype) {
            tableName = cateinfo.get("ITEM_TABLE_NAME");
            if(3==datatype){//根据项目查项目
                idsql=String.valueOf(id);
            }else if(1==datatype){//根据卷查项目信息
                idsql="select item_id from "+itemvtable+" where folder_id="+id;
            }else if(0==datatype){//根据件查项目信息
                idsql="select item_id from "+itemvtable+ " where folder_id=(select folder_id from "+fvtable+" where da_id="+id+")" ;
            }
        }
        Map<String,Object> map=detailMapper.getdatainfo(fields,tableName,idsql);
        //获取分类
        List<Map<String,String>> zsfllist=detailMapper.zsfllist(mdatalisttable,infotype,categoryId,catetablename);
        for (int i = 0; i <zsfllist.size(); i++) {
            Map mapi=zsfllist.get(i);
            mapi.put("value",map.get(mapi.get("FIELD_NAME")));
            zsfllist.set(i,mapi);
        }
        returnjson.put("datalist",zsfllist);
        return returnjson;
    }

    @Override
    public JSONObject getefileinfo(JSONObject json) {
        Long daid=json.getLong("id");
        TenantCategory tenantCategory=new TenantCategory();
        String catetablename=tenantCategory.getTableName();
        TenantMdataList tenantMdataList=new TenantMdataList();
        String mdatalisttable=tenantMdataList.getTableName();
        TenantYqda tenantYqda=new TenantYqda();
        String allftable=tenantYqda.getTableName();
        String efiletable=tenantYqdaDocumentMapper.gettablenamebydaid(daid,allftable,catetablename);
        //获取所有efile字段
        String fields=detailMapper.getefilefield(daid,catetablename,mdatalisttable,allftable);
        //获取efile信息
        List<Map<String,Object>> efilelist=tenantYqdaDocumentMapper.getefilebydaid(daid,efiletable,"DOC_ID,"+fields);
        //获取是否展示
        List<Map<String,String>> showmaplist=detailMapper.getshowmap(daid,catetablename,mdatalisttable,allftable);
        List  returnlist=new ArrayList();
        for (int i = 0; i < efilelist.size(); i++) {
            for (int j = 0; j < showmaplist.size(); j++) {
                Map mapi=showmaplist.get(j);
                mapi.put("value",efilelist.get(i).get(mapi.get("FIELD_NAME")));
                showmaplist.set(j,mapi);
            }
            //主键
            Map map=new HashMap(1<<2);
            map.put("FIELD_CAPTION","doc主键");
            map.put("IS_HIDDEN","0");
            map.put("FIELD_NAME","DOC_ID");
            map.put("value",efilelist.get(i).get("DOC_ID"));
            showmaplist.add(map);
            List<Map<String,String>> copylist=new ArrayList<>();
            copylist.addAll(showmaplist);
            returnlist.add(copylist);
            showmaplist.remove(showmaplist.size()-1);
        }
        JSONObject returnjson=new JSONObject();
        returnjson.put("list",returnlist);
        return returnjson;
    }

    @Override
    public List<Map<String, Object>> getlistbyparentId(JSONObject json) {
        Long categoryId = json.getLong("categoryId");//门类id
        Long menuId = json.getLong("menuId");//菜单id
        Long parentId=json.getLong("parentId");//父级id
        int level=json.getInteger("level");
        String fields="id,"+json.getString("fields");//需要查询的字段
        JSONArray jsonArray = json.getJSONArray("searchcolumn");//查询条件
        StringBuilder sb=new StringBuilder(" and ");//用于拼接条件
        String orderstr=json.getString("order");//用于排序
        String isDel=json.getString("isDel");//回收站时查看删除当男
        if(null==isDel||"null".equals(isDel)){
            isDel="0";
        }
        int type=-1;
        /**处理查询条件*/
        if(null==jsonArray){
            jsonArray=new JSONArray();
        }
        if(jsonArray.size()>0){
            wenjianzhengliService.concatQueryCondition(jsonArray,sb);
        }
        /**处理表名*/
        TenantCategory category=new TenantCategory();
        String tablename="";
        String relasql="";
        TenantCategory tenantCategory = categoryMapper.selectTenantCategoryByID(categoryId, category.getTableName());
        String parentTable= "";
        if (level==3){//项目找卷
            parentTable = tenantCategory.getItemTableName();
            tablename=tenantCategory.getFolderTableName();
            TenantItemFolder itemFolder=new TenantItemFolder();
            relasql=" select folder_id from "+itemFolder.getTableName()+" where item_id="+parentId;
            type=1;
        }else if(level==1){//卷
            parentTable = tenantCategory.getFolderTableName();
            tablename=tenantCategory.getFileTableName();
            TenantYqdaFolder yqdaFolder=new TenantYqdaFolder();
            relasql=" select da_id from "+yqdaFolder.getTableName()+" where folder_id="+parentId;
            type=0;
        }
        Map<String,Object> stateMap = archiveMapper.getArchiveDataById("STATE",parentId,parentTable);
        int state = (int) stateMap.get("STATE");
        sb.append(" STATE = ").append(state);
        String tiaojian=sb.toString();
        /**处理拼接条件时的sql*/
        if (tiaojian.endsWith("and ")){
            tiaojian=tiaojian.substring(0,tiaojian.length()-4);
        }else if(tiaojian.endsWith("and")){
            tiaojian=tiaojian.substring(0,tiaojian.length()-3);
        }
        /**处理排序*/
        if(null!=orderstr&&!"".equals(orderstr)){
            orderstr=" order by "+orderstr;
        }else{
            String applyorderstr=tenantMdataListService.getorder(categoryId, menuId, type);
            if(null!=applyorderstr&&!"".equals(applyorderstr)){
                orderstr=" order by "+applyorderstr;
            }
        }
        PageUtils.startPage();
        /**查询列表并返回*/
        return detailMapper.getlistbytreenode(fields,tablename,tiaojian,relasql,isDel,orderstr);
    }

    @Override
    public List<Map<String, Object>> getefileinfobydocid(JSONObject json) {
        Long docId=json.getLong("docId");
        String fields=json.getString("fields");
        Long categoryId=json.getLong("categoryId");
        TenantCategory tenantCategory = categoryMapper.selectTenantCategoryByID(categoryId, new TenantCategory().getTableName());
        return detailMapper.getefileinfobydocid(docId,fields,tenantCategory.getEfileTableName());
    }

    @Override
    public List<Map<String, Object>> getmultipleinfo(JSONObject json) {
        Long categoryId=json.getLong("categoryId");
        String nowtype=json.getString("nowtype");
        String needtype=json.getString("needtype");
        List ids = json.getJSONArray("ids");
        String fields=json.getString("fields");
        String menuId = json.getString("menuId");
        String xvtable=new TenantYqKfjdItemFolder().getTableName();
        String vftable=new TenantYqdaFolder().getTableName();
        TenantCategory tenantCategory = categoryMapper.selectTenantCategoryByID(categoryId, new TenantCategory().getTableName());
        String tableName="";
        String idsql="";
        String listids=ids.toString().replace("[","").replace("]","").replace("\"","").replace(" ","");
        String field = "";
        if("x".equals(nowtype)){//项目id
            if("v".equals(needtype)){//获取案卷
                field ="juanorder";
                tableName=tenantCategory.getFolderTableName();
                idsql=" select folder_id from "+xvtable+" where item_id in("+listids+")";
            }else if("f".equals(needtype)){//获取件
                field = "jianorder";
                tableName=tenantCategory.getFileTableName();
                idsql=" select da_id from "+vftable+" where folder_id in(select folder_id from "+xvtable+" where item_id in("+listids+"))";
            }
        }else if("v".equals(nowtype)){//案卷id
            if("f".equals(needtype)){//获取件
                field = "jianorder";
                tableName=tenantCategory.getFileTableName();
                idsql=" select da_id from "+vftable+" where folder_id in("+listids+")";
            }
        }
        String getfieldlist = tenantApplyMapper.getfieldlist(json.getLong("menuId"),
                json.getLong("categoryId"), field, new TenantApply().getTableName());
        String orderstr = StringUtils.isNotEmpty(getfieldlist) ? "order by " + (getfieldlist.replace("$", " ")) : "";
        return detailMapper.getmultipleinfo(fields,tableName,idsql,orderstr);
    }

    @Override
    public void download(Long doc_id, String daId, String categoryId,String borrowId,String menuId,String sydm, HttpServletResponse response) throws Exception{
        TenantCategory tenantCategory=new TenantCategory();
        String catetablename=tenantCategory.getTableName();
        TenantYqda tenantYqda=new TenantYqda();
        String allftable=tenantYqda.getTableName();
        String efiletable="";
        if(null==daId){
            tenantCategory.setCategoryId(Long.parseLong(categoryId));
            TenantCategory tenantCategory1 = categoryMapper.selectTenantCategoryList(tenantCategory).get(0);
            efiletable=tenantCategory1.getEfileTableName();
        }else{
            efiletable=documentMapper.gettablenamebydaid(Long.parseLong(daId),allftable,catetablename);
        }
        TenantYqdaDocument document=documentMapper.selectnameandpathbyDocid(doc_id,efiletable);
        String filePath=document.getDocMnt()+ File.separator+document.getPath();
        File f = new File(filePath);
        if (!f.exists()) {
            throw new ServiceException("文件不存在!");
            //response.sendError(404, "File not found!");
            //return ResponseData.error("File not found!");
        }

        //添加水印
        if (StringUtils.isNotEmpty(sydm)){
            YqSy yqSy = new YqSy();
            yqSy.setSydm(sydm);
            yqSy = yqSyService.selectYqSyBySydm(yqSy);
            if (null!=yqSy&&StringUtils.isNotEmpty(yqSy.getSynr())){
                if(!FileWaterMark.PdfIsEncryption(filePath)){
                    String fpath = f.getPath();
                    String fileFullName = fpath.substring(fpath.lastIndexOf("\\")+1,fpath.lastIndexOf("."));
                    String prefix=fpath.substring(fpath.lastIndexOf(".")+1);
                    String 	waterMarkFilepath = sysConfigService.selectConfigByKey("WATERMARKFILEPATH");
                    //生成水印文件地址
                    if(!StringUtils.isEmpty(waterMarkFilepath)) {
                        File folder = new File(waterMarkFilepath);
                        if (!folder.exists()) {
                            if (folder.mkdirs()) {

                            }else {
                                throw new RuntimeException("路径"+waterMarkFilepath+"不存在！");
                            }
                        }
                        waterMarkFilepath+=fileFullName+"."+prefix;
                    }else {
                        throw new RuntimeException("没有在系统参数表配置添加水印文件保存路径WATERMARKFILEPATH字段");
                    }
                    if("pdf".equals(prefix.toLowerCase())) {
                        FileWaterMark.pdfWaterMark(fpath,waterMarkFilepath,yqSy);
                        f = new File(waterMarkFilepath);
                    } else if ("png".equals(prefix.toLowerCase())||"jpg".equals(prefix.toLowerCase())||"jpeg".equals(prefix.toLowerCase())) {
                        FileWaterMark.addPictureWaterMark(fpath,waterMarkFilepath,yqSy);
                        f = new File(waterMarkFilepath);
                    }
                }
            }
        }


        BufferedInputStream br = new BufferedInputStream(new FileInputStream(f));
        byte[] buf = new byte[1024];
        int len = 0;
        boolean isOnLine=true;
        response.reset(); // 非常重要
        ResponseUtils.defaultResponse(response);
        String  fileName= document.getDocName();

        if (isOnLine) { // 在线打开方式
            URL u = new URL("file:///" + filePath);
            response.setContentType(u.openConnection().getContentType());
            response.setHeader("Content-Disposition", "inline; filename=\"" + fileName+"\"");
            // 文件名应该编码成UTF-8
        } else { // 纯下载方式
            response.setContentType("application/x-msdownload");
            response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
        }
        OutputStream out = response.getOutputStream();
        while ((len = br.read(buf)) > 0){
            out.write(buf, 0, len);
        }
        br.close();
        out.close();

        //添加下载记录
        LoginUser user = SecurityUtils.getLoginUser();
        TenantDownloadRecord downloadRecord = new TenantDownloadRecord();
        downloadRecord.setCreateTime(new Date());
        downloadRecord.setDocId(doc_id);
        downloadRecord.setDownloadUserId(user.getUserId());
        downloadRecord.setMenuId(Long.valueOf(menuId));
        downloadRecord.setFrequency(1);
        downloadRecord.setBorrowId(Long.valueOf(borrowId));
        downloadRecord.setCategoryId(Long.valueOf(categoryId));
        tenantDownloadRecordSerive.insertTenantDownloadRecord(downloadRecord);
    }

    @Override
    public List<Map<String, Object>> getjianlistbyitemId(JSONObject json) {
        Long categoryId = json.getLong("categoryId");//门类id
        Long menuId = json.getLong("menuId");//菜单id
        Long itemId=json.getLong("itemId");//项目id
        String fields="id,"+json.getString("fields");//需要查询的字段
        JSONArray jsonArray = json.getJSONArray("searchcolumn");//查询条件
        StringBuilder sb=new StringBuilder(" and ");//用于拼接条件
        String orderstr=json.getString("order");//用于排序
        String isDel=json.getString("isDel");//回收站时查看删除当男
        if(null==isDel||"null".equals(isDel)){
            isDel="0";
        }
        int type=-1;
        /**处理查询条件*/
        if(null==jsonArray){
            jsonArray=new JSONArray();
        }
        if(jsonArray.size()>0){
            wenjianzhengliService.concatQueryCondition(jsonArray,sb);
        }
        /**处理表名*/
        TenantCategory category=new TenantCategory();
        String tablename="";
        String relasql="";
        TenantCategory tenantCategory = categoryMapper.selectTenantCategoryByID(categoryId, category.getTableName());
        tablename=tenantCategory.getFileTableName();
        TenantYqdaFolder yqdaFolder=new TenantYqdaFolder();
        relasql=" select da_id from "+yqdaFolder.getTableName()+" where folder_id is null and item_id="+itemId; //只查询没有关联卷id的件
        type=0;
        String tiaojian=sb.toString();
        /**处理拼接条件时的sql*/
        if (tiaojian.endsWith("and ")){
            tiaojian=tiaojian.substring(0,tiaojian.length()-4);
        }else if(tiaojian.endsWith("and")){
            tiaojian=tiaojian.substring(0,tiaojian.length()-3);
        }
        /**处理排序*/
        if(null!=orderstr&&!"".equals(orderstr)){
            orderstr=" order by "+orderstr;
        }else{
            String applyorderstr=tenantMdataListService.getorder(categoryId, menuId, type);
            if(null!=applyorderstr&&!"".equals(applyorderstr)){
                orderstr=" order by "+applyorderstr;
            }
        }
        PageUtils.startPage();
        /**查询列表并返回*/
        return detailMapper.getlistbytreenode(fields,tablename,tiaojian,relasql,isDel,orderstr);
    }

    @Override
    public List<Map<String, Object>> getjianlistbyjianids(JSONObject json) {
        Long categoryId = json.getLong("categoryId");//门类id
        Long menuId = json.getLong("menuId");//菜单id
        String jianids=json.getString("jianids");//件ids
        String fields="id,"+json.getString("fields");//需要查询的字段
        StringBuilder sb=new StringBuilder(" and ");//用于拼接条件
        String orderstr=json.getString("order");//用于排序
        String isDel=json.getString("isDel");//回收站时查看删除当男
        if(null==isDel||"null".equals(isDel)){
            isDel="0";
        }
        int type=-1;
        /**处理表名*/
        TenantCategory category=new TenantCategory();
        String tablename="";
        String relasql="";
        TenantCategory tenantCategory = categoryMapper.selectTenantCategoryByID(categoryId, category.getTableName());
        tablename=tenantCategory.getFileTableName();
        TenantYqdaFolder yqdaFolder=new TenantYqdaFolder();

        type=0;
        String tiaojian=sb.toString();
        /**处理拼接条件时的sql*/
        if (tiaojian.endsWith("and ")){
            tiaojian=tiaojian.substring(0,tiaojian.length()-4);
        }else if(tiaojian.endsWith("and")){
            tiaojian=tiaojian.substring(0,tiaojian.length()-3);
        }
        /**处理排序*/
        if(null!=orderstr&&!"".equals(orderstr)){
            orderstr=" order by "+orderstr;
        }else{
            String applyorderstr=tenantMdataListService.getorder(categoryId, menuId, type);
            if(null!=applyorderstr&&!"".equals(applyorderstr)){
                orderstr=" order by "+applyorderstr;
            }
        }
        PageUtils.startPage();
        /**查询列表并返回*/
        return detailMapper.getlistbytreenode(fields,tablename,tiaojian, jianids.replace("[","").replace("]","").replace(" ",""),isDel,orderstr);
    }

    /**
     * 云阅读水印
     * @return
     */
    @Override
    public WebOFDExplicitWaterMarkInfo getWatermarkData(YqSy yqSy) {
        WebOFDExplicitWaterMarkInfo waterMarkInfo = new WebOFDExplicitWaterMarkInfo();
        /* 组织显式水印数据 */
        //显式水印内容样板
        waterMarkInfo.setContent(yqSy.getSynr());
        //字体
        waterMarkInfo.setFontStyle(yqSy.getFont());
        waterMarkInfo.setFontSize(Integer.parseInt(yqSy.getFontsize()));
        //颜色
        waterMarkInfo.setFontColor(yqSy.getColor());
        waterMarkInfo.setIsExplicit("1");
        waterMarkInfo.setIsShowExplicit("1");
        waterMarkInfo.setIsPrintExplicit("1");
        waterMarkInfo.setIsText("1");
        waterMarkInfo.setIsImage("0");
        if (waterMarkInfo.getIsImage().equals("1")) {
            waterMarkInfo.setImage(this.getWatermarkImageBase64());
        }
        waterMarkInfo.setScale("2");
        waterMarkInfo.setRotation(45);
        waterMarkInfo.setDiaphaneity(String.valueOf(yqSy.getTransparency()));
        waterMarkInfo.setPosition("001010101");
        return waterMarkInfo;
    }

    public String getWatermarkImageBase64() {
        String pngName = "LOGO.png";
        String webAppFilesPath = CommonExtensionUtils.webAppTempFilePath();
        String fileStr = CommonExtensionUtils.getFileStr("D:\\download" + File.separator + pngName);
        return fileStr;
    }

    public WebOFDExplicitWaterMarkInfo getWatermarkDataMk2() {
        String targetDir = System.getProperty("os.name").toLowerCase().contains("win") ? BaseController.DEFAULT_TEMP_DIR_WIN : BaseController.DEFAULT_TEMP_DIR_LINUX;
        String json = CommonExtensionUtils.readJsonFile(targetDir + "testWatermarkData.json");
        return new Gson().fromJson(json, WebOFDExplicitWaterMarkInfo.class);
    }

    /* 组织权限内容JSON */
    @Override
    public WebOFDPermissionInfo getPermissionData() {
        /* 组织权限数据 */
        WebOFDPermissionInfo permissionInfo = new WebOFDPermissionInfo();
        permissionInfo.setPermission("2");				/* 权限总开关 2-有权限  0-无任何权限	 */
        permissionInfo.setHead("1");					/* LOGO栏		 */
        permissionInfo.setOpenFileBtn("0");				/* 打开文件按钮 	 */
        permissionInfo.setSaveBtn("0");					/* 保存文件按钮	 */
        permissionInfo.setPrintBtn("1");				/* 打印按钮		 */
        permissionInfo.setGoToPageBox("1");				/* 跳转指定页框	 */
        permissionInfo.setZoomPageBox("1");				/* 页面缩放		 */
        permissionInfo.setPageLayoutBtn("0");			/* 页面布局		 */
        permissionInfo.setHandToolBtn("0");				/* 手型工具		 */
        permissionInfo.setTextSelectBtn("0");			/* 选择文本工具 	 */
        permissionInfo.setHeightLightBtn("0");			/* 高亮			 */
        permissionInfo.setUnderlineBtn("0");			/* 下划线		 */
        permissionInfo.setPencilBtn("0");				/* 铅笔			 */
        permissionInfo.setDrawingAnnotBtn("0");			/* 其他标注		 */
        permissionInfo.setCommentsBtn("0");				/* 注释			 */
        permissionInfo.setElecSignatureBtn("0");		/* 签章			 */
        permissionInfo.setCheckElecSignatureBtn("0");	/* 验章			 */
        permissionInfo.setRotateSwitchBtn("0");			/* 页面旋转		 */
        permissionInfo.setExportBtn("0");				/* 下载文档		 */

        permissionInfo.setOutlineBtn("0");				/* 大纲			 */
        permissionInfo.setThumbnailBtn("0");			/* 缩略图		 */
        permissionInfo.setCommentListBtn("0");			/* 注释评论		 */
        permissionInfo.setSearchBtn("0");				/* 查找			 */
        permissionInfo.setSemanticTreeBtn("0");			/* 语义树		 */
        permissionInfo.setAttachmentBtn("0");			/* 附件			 */

        /* 阅读页数控制字段 */
        permissionInfo.setPageRange("1,2,3-4");
        /* 阅读时间控制 */
        permissionInfo.setTimeModel(WebOFDTimeModelEnum.UNLIMITED_TIME.getTimeModel());
        /* 在线阅读起始时间 */
        //permissionInfo.setOnlineReadBeginTime("2021-04-08 15:30:00");
        /* 在线阅读结束时间 */
        //permissionInfo.setOnlineReadTime("2021-04-08 12:00:00");

        /* 隐写溯源三项 */
        permissionInfo.setIsImplicit("0");	/* 实际环境中,仅需控制这个开关即可，其他两个字段为保留字段供后期需求使用 */
        permissionInfo.setIsPrintImplicit("0");
        permissionInfo.setIsShowImplicit("0");

        /* 遮盖预遮盖 */
        permissionInfo.setAreaSelectBtn("0");		/* 区域选择工具开关-遮盖相关所有功能的开关 */
        permissionInfo.setCover("0");
        permissionInfo.setPreCover("0");


        return permissionInfo;
    }
    /* 组织权限内容JSON */
    private WebOFDPermissionInfo getPermissionDataMk2() {
        /* 组织权限数据 */
        String targetDir = System.getProperty("os.name").toLowerCase().contains("win") ? BaseController.DEFAULT_TEMP_DIR_WIN : BaseController.DEFAULT_TEMP_DIR_LINUX;
        String json = CommonExtensionUtils.readJsonFile(targetDir + "testPermissionData.json");
        return new Gson().fromJson(json, WebOFDPermissionInfo.class);
    }

}
